//
//  CZUser.swift
//  weibo10
//
//  Created by apple on 16/5/20.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

//用户模型
class CZUser: NSObject
{

 //用户ID 
    var id: Int64 = 0
    
    //用户昵称
    var screen_name: String?
    
    //用户头像地址
    var profile_image_url: String?
    
    //是否是微博认证用户  没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1
        {
        didSet
            {
        // kvc赋值认证类型,知道当前是什么认证类型,根据认证类型创建对应的图片
           switch verified_type
           {
           case 0: verifiedImage = UIImage(named: "avatar_vip")
           case 2,3,5: verifiedImage = UIImage(named: "avatar_enterprise_vip")
           case 220: verifiedImage = UIImage(named: "avatar_grassroot")
           default:
            //其他情况
            verifiedImage = nil
                }
            
        }
    }
    
    
    //模型提供认证类型图片
    var verifiedImage: UIImage?
    
    //会员等级 1 - 6
    var mbrank: Int = 0
        {
        
    didSet
    {
        // kvc设置会员等级的,知道自己是几级,就创建对应的图片
        if mbrank > 0 && mbrank <= 6
        {
        mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
        }else
        {
        mbrankImage = nil
        }
        
        }
    
    }
    
    //模型提供会员等级图片
    var mbrankImage: UIImage?
    
    init(dict: [String: AnyObject])
    {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String)
    {}
    
  override  var description: String
        {
    
    get{
        let keys = ["id","screen_name","profile_image_url","verified_type","mbrank"]
        return "\n \t \t用户模型: \(dictionaryWithValuesForKeys(keys))"
        
        }
    }
    
}
